package com.atguigu.flink.splitAndUnionStream;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class SplitStreamByFilter {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<String> socketSD = env.socketTextStream("hadoop102", 8888);
        SingleOutputStreamOperator<Integer> mapDS = socketSD.map(Integer::valueOf);
        SingleOutputStreamOperator<Integer> ds1 = mapDS.filter(x -> x % 2 == 0);
        SingleOutputStreamOperator<Integer> ds2 = mapDS.filter(x -> x % 2 == 1);
        ds1.print("偶数");
        ds2.print("奇数");

        env.execute();

    }
}
